package com.example.springaop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Order(100)
@Slf4j
@Aspect
//@Component
public class AspectDemo {
    //定义切点
    @Pointcut("execution(* com.example.springaop.controller.*.*(..))")
    public void pt(){};
    //环绕通知
    @Around("pt()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("Around 开始执行");
        Object proceed = joinPoint.proceed();
        log.info("Around 执行结束");
        return proceed;
    }
    //前置通知
    @Before("pt()")
    public void doBefore(){
        log.info("before 执行");
    }
    @After("pt()")
    public void doAfter(){
        log.info("After 执行");
    }
    @AfterReturning("pt()")
    public void doAfterReturning(){
        log.info("AfterReturnin 执行");
    }
    @AfterThrowing("pt()")
    public void doAfterThrowin(){
        log.info("doAfterThrowin 执行");
    }
}
